package com.zoo.diannaopeijian.service.impl;

import com.zoo.diannaopeijian.comm.page.Page;
import com.zoo.diannaopeijian.comm.sql.GeneratorExampleBuilder;
import com.zoo.diannaopeijian.domain.*;
import com.zoo.diannaopeijian.mapper.ComponentMapper;
import com.zoo.diannaopeijian.mapper.ComponentParameterDetailMapper;
import com.zoo.diannaopeijian.mapper.ComponentParameterMapper;
import com.zoo.diannaopeijian.service.ComponentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by zx583 on 2018-01-14.
 */
@Service
public class ComponentServiceImpl implements ComponentService {
    @Resource
    private ComponentMapper componentMapper;

    @Override
    public boolean addComponent(Component component) {
        return componentMapper.insertSelective(component) == 1;
    }

    @Override
    public boolean updateComponent(Component component) {
        return componentMapper.updateByPrimaryKeySelective(component) == 1;
    }

    @Override
    public boolean deleteComponent(Integer componentid) {
        return componentMapper.deleteByPrimaryKey(componentid) == 1;
    }





    @Override
    public List<Component> getComponent(Component component) {
        ComponentExample example = (ComponentExample) GeneratorExampleBuilder.buildEqualExample(ComponentExample.class, component, true);
        return componentMapper.selectByExample(example);
    }

    @Override
    public List<Component> getComponentWithPage(Component component, Page page) {
        page.onPage();

        return getComponent(component);
    }




}
